<style lang="less">

</style>

<template>
  <div class="rightContBigBox">
    <filter-box
      v-show='this.$route.name == "noticeList"'
      :getButtonConfig='getButtonConfig'
      v-on:setFilterParams='setFormParams'
    ></filter-box>

    <table-box
      v-show='this.$route.name == "noticeList"'
      :formData='formData'
      :formLoading='formLoading'
      :totalSize='totalSize'
      :getButtonConfig='getButtonConfig'
      v-on:setTableParams='setFormParams'
      v-on:reloadPage='reloadPage'
    ></table-box>

    <div v-show='this.$route.name == "editNotice" '>
      <transition >
        <router-view
          v-on:setTitleMsg='setTitleMsg'
          v-on:reloadPage='reloadPage'
            
        ></router-view>
      </transition>
    </div>

    </div>

  
</template>

<script>
  
  import filterBox from './filterBox.vue'
  import tableBox from './tableBox.vue'
  import {getNoticeList} from 'api/noticeManage/index.js'
  export default {
    components:{
      filterBox,
      tableBox,
    },
    data(){
      return{
        paramsData:{
          orderBy:'lastUpdated',
          xsc:'DESC',
        },
        formData:[],
        totalSize:0,
        formLoading:false,//内容列表table是否在加载

      }
    },
    computed:{
      getButtonConfig(){
        console.log('index:  computed getButtonConfig', this.$store.getters.getButtonConfig('noticeList'))
        return this.$store.getters.getButtonConfig('noticeList')
      },
    },
    methods:{
      setFormParams(params){
        console.log('setFormParams', params)
        Object.assign(this.paramsData, params)
        this.getNoticeList(this.paramsData)
      },
      async getNoticeList(params){
        try{
          this.formLoading = true
          let back = await getNoticeList(params)
          back = back.data;
          console.log('getNoticeList', back)
          this.formLoading = false
          if(back && back.resultCode =='200'){
            this.formData= back.result ? back.result :[];
            this.totalSize= back.size ? back.size :0;
            
          }else{
            this.$alert(back.msg)
          }
        }catch(err){
          this.formLoading = false
          this.$alert('查询错误！')
          console.error(err)
        }
      },
      reloadPage(){
        console.log('数据有变，重新加载咯！')
        this.getNoticeList(this.paramsData)
      },
      setTitleMsg(msg){
        this.$emit('setTitleMsg', msg)
      }
    },
    created(){
      this.setTitleMsg(['公告管理', '公告列表'])
    }
  }
</script>
